<div>

  <!-- 面包屑导航 -->
  <el-breadcrumb separator-class="el-icon-arrow-right">
    <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item>用户管理</el-breadcrumb-item>
    <el-breadcrumb-item>用户列表</el-breadcrumb-item>
  </el-breadcrumb>

  <!-- 搜索 -->
  <el-row>
    <el-col :span="12">
      <el-input placeholder="请输入一只小喵咪" v-model="queryTxt">
        <el-button slot="append" icon="el-icon-search" @click="loadUsersList(1, queryTxt)"></el-button>
      </el-input>
    </el-col>
    <!-- 添加用户 -->
    <el-col :span="4">
      <el-button style="margin-left: 20px" @click='showAddUserBox'>添加用户
      </el-button>
    </el-col>
  </el-row>

  <!-- 列表 -->
  <el-table :data="usersData" stripe style="width: 100%">
    <el-table-column prop="username" label="姓名" width="180"></el-table-column>
    <el-table-column prop="email" label="邮箱" width="180"></el-table-column>
    <el-table-column prop="mobile" label="电话" width="180"></el-table-column>
    <!-- 用户状态 -->
    <el-table-column label="用户状态" width="180">
      <template slot-scope="scope">
        <el-switch v-model="scope.row.mg_state"></el-switch>
      </template>
    </el-table-column>
    <!-- 操作 -->
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button size="mini" plain type="primary" icon="el-icon-edit" @click='edit(scope.row)'></el-button>
        <el-button size="mini" plain type="danger" icon="el-icon-delete" @click='del(scope.row.id)'></el-button>
        <el-button size="mini" plain type="success" icon="el-icon-check">分配角色</el-button>
      </template>
    </el-table-column>
  </el-table>

  <!-- 添加用户 - 详情页 -->
  <el-dialog title="添加用户" :visible.sync="dialogFormVisible" @close="userBoxClosed">
    <el-form :model="addUserForm" :rules="rules" ref='addUserForm' label-width="80px">
      <el-form-item label="用户名" prop="username">
        <el-input v-model="addUserForm.username"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="password">
        <el-input v-model="addUserForm.password"></el-input>
      </el-form-item>
      <el-form-item label="邮箱" prop="email">
        <el-input v-model="addUserForm.email"></el-input>
      </el-form-item>
      <el-form-item label="手机" prop="mobile">
        <el-input v-model="addUserForm.mobile"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible = false">取 消</el-button>
      <el-button type="primary" @click="addUser">确 定</el-button>
    </div>
  </el-dialog>

  <!-- 修改用户 - 详情页 -->
  <el-dialog title="修改用户" :visible.sync="editShow">
    <el-form :model="addUserForm" :rules="rules" label-width="80px">
      <el-form-item label="用户名" prop="username">
        <el-input v-model="addUserForm.username"> {{addUserForm.username}} </el-input>
      </el-form-item>
      <el-form-item label="邮箱">
        <el-input v-model="addUserForm.email">{{addUserForm.email}}</el-input>
      </el-form-item>
      <el-form-item label="手机">
        <el-input v-model="addUserForm.mobile">{{addUserForm.mobile}}</el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="editShow=false">取 消</el-button>
      <el-button type="primary" @click="putUser(addUserForm.id)">确 定</el-button>
    </div>
  </el-dialog>

  <!-- 分页标签 -->
  <el-pagination background layout="prev, pager, next" :total="total" :page-size="2"
    @current-change="loadUsersList($event, queryTxt)" :current-page="pagenum || 1"></el-pagination>
</div>
